<?php
class Mivec_Http_Socket extends Mivec_Http_Abstract
{
	protected $_config = array(
		'adapter'	=> 'Zend_Http_Client_Adapter_Socket'
	);
	protected $_adapter;
	protected $_url;
	
	protected $_response;
	
	public function __construct($_url)
	{
		$this->_url = $_url;
		self::_init();
	}
	
	private function _init()
	{
		if (strpos($this->_url,'http') === false) {
			//$this->_url = 'http://' . $this->_url;
		}
		
		$this->_adapter = new Zend_Http_Client($this->_url,$this->_config);
	}
	
	public function request($_method="")
	{
		$this->_response = $this->_adapter->request($_method="");
		return $this;
	}
	
	public function getHeaders()
	{
		if ($this->_response instanceof Zend_Http_Response) {
			return $this->_response->getHeaders();
		} else {
			throw new Exception("Unknow Object");
		}
	}
	
	public function getStatus()
	{
		if ($this->_response instanceof Zend_Http_Response) {
			return $this->_response->getStatus();
		} else {
			throw new Exception("Unknow Object");
		}
	}
	
	public function getBody()
	{
		if ($this->_response instanceof Zend_Http_Response) {
			return $this->_response->getRawBody();
		} else {
			throw new Exception("Unknow Object");
		}
	}
}